import { useMutation, useQuery } from "react-query";
import { useRequest } from "../../utils/request";

/**
 * !获取矛盾调解步骤接口
 * @returns
 */
export const useGetBeefStepByBeefId = (queryParams: { beefId: string }) => {
  const request = useRequest<IBeefSolveStep[]>();
  return useQuery(["getBeefStepByBeefId", queryParams], () =>
    request("/beef/getBeefStepByBeefId", { data: queryParams })
  );
};

/**
 * ! 添加矛盾纠纷调解步骤接口/beef/pushCenter
 * @returns
 */
export const useAddBeefSolveStep = () => {
  const request = useRequest<string>();
  return useMutation(async (params: IAddBeefSolveStep) => {
    const result = request("/beef/mediate", {
      data: params,
      method: "POST",
      json:true
    });
    return result;
  });
};
/**
 * ! 推送到综治中心接口
 * @returns
 */
export const usePushBeefSolveStep = () => {
  const request = useRequest<string>();
  return useMutation(async (params: IAddBeefSolveStep) => {
    const result = request("/beef/pushCenter", {
      data: params,
      method: "POST",
    });
    return result;
  });
};
/**
 * ! 推送到综治中心接口
 * @returns
 */
export const useSignBeefSolveStep = () => {
  const request = useRequest<string>();
  return useMutation(async (params: IAddBeefSolveStep) => {
    const result = request("/beef/sign", {
      data: params,
      method: "POST",
    });
    return result;
  });
};
/**
 * ! 退回重新调解接口
 * @returns
 */
export const useRollbackBeefSolveStep = () => {
  const request = useRequest<string>();
  return useMutation(async (params: IAddBeefSolveStep) => {
    const result = request("/beef/rollback", {
      data: params,
      method: "POST",
    });
    return result;
  });
};
/**
 * ! 综治中心指派给社区书记
 * @returns
 */
export const usePushAppointBeefSolveStep = () => {
  const request = useRequest<string>();
  return useMutation(async (params: any) => {
    const result = request("/beef/pushAppoint", {
      data: params,
      method: "POST",
    });
    return result;
  });
};
/**
 * ! 结束矛盾纠纷调解步骤接口
 * @returns
 */
export const useOverBeefSolveStep = () => {
  const request = useRequest<string>();
  return useMutation(async (params: IAddBeefSolveStep) => {
    const result = request("/beef/mediated", {
      data: params,
      method: "POST",
    });
    return result;
  });
};
/**
 * ! 彻底结束矛盾纠纷调解步骤接口(已经电话回访)
 * @returns
 */
export const useConfirmEndBeefSolveStep = () => {
  const request = useRequest<string>();
  return useMutation(async (params: IAddBeefSolveStep) => {
    const result = request("/beef/confirmEnd", {
      data: params,
      method: "POST",
    });
    return result;
  });
};
export type IAddBeefSolveStep = {
  /**
   * 矛盾纠纷调解级别
   * 流程状态; 1=申请;2签收;3=指派人员处理;4=调解; 5=确认;6=电话回访; 7=退回流程;8=取消;100=综治中心
   */
  // beefLevel: number;

  /**
   * 关联矛盾纠纷ID
   */
  beefId: string;
  /**
   * 矛盾纠纷提交描述
   */
  beefSolveStepDesp?: string;

  /**
   * 相关图片
   */
  imgUrls?: string[];

  /**
   * 指定用户的ID
   */
  solveUserId?: string;

};

/**
 * 流程
 */
export type IBeefSolveStep = {
  /**
   * 矛盾调解步骤ID
   */

  beefSolveStepId: string;

  /**
   * 矛盾纠纷提交描述
   */
  beefSolveStepDesp: string;

  /**
   * 矛盾纠纷调解时间
   */
  beefSolveCreateTime: string;

  /**
   * 矛盾纠纷调解级别
   * 流程状态; 1=申请;2签收;3=指派人员处理;4=调解; 5=确认;6=电话回访; 7=退回流程;8=取消;100=综治中心
   */
  beefLevel: number;

  /**
   * 流程用户ID
   */
  userId: string;

  /**
   * 流程用户名称
   */

  userName: string;

  /**
   * 关联矛盾纠纷ID
   */
  beefId: string;

  /**
   * 用户角色名称
   */
  sysRoleName: string;

  /**
   * 图片附件
   */
  imgUrls: string[];
};
